<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品列表</title>
    <style>
        h1{
            text-align: center;
        }
        table{
            border-collapse: collapse;
            width:600px;
            margin: 0 auto;
        }
        td,th{
            border:1px solid darkblue;
            height: 40px;
            text-align:center;
        }
        tr:nth-child(odd){
            background-color: lightgrey;
        }

    </style>
    <script th:src="@{/webjars/jquery/3.4.1/dist/jquery.min.js}"></script>
    <script>
        $(function(){
           $(".delete").click(function(){
               var r=confirm("您是否确定删除");
               if(r){
                   var href=this.href;
                   $("#f1").attr("action",href);
                   $("#f1").submit();
                   return false;
               }
              return false;
           });
        });
    </script>
</head>
<body>
    <h1>商品列表</h1>
    <a th:href="@{itemCategory/view}">新增商品</a>
    <table>
        <tr>
            <th>分类名称</th>
            <th>上级分类id</th>
            <th>分类说明</th>
            <th>操作</th>
        </tr>
        <tr th:each="itemCategory:${ics}">
            <td th:text="${itemCategory.name}"></td>
            <td th:text="${itemCategory.pid}"></td>
            <td th:text="${itemCategory.remark}"></td>
            <td>
                <a th:href="@{|/itemCategory/${itemCategory.id}|}">修改</a>
                |
                <a class="delete" th:href="@{|/itemCategory/${itemCategory.id}|}">删除</a>
            </td>
        </tr>
    </table>

</body>
<form id="f1" method="post">
    <input type="hidden" name="_method" value="delete">
</form>
</html>